	$(function() {
		$(window).on("load", initData);
		//完成编辑去档案列表页面
		$("#eos").bind("click", toList);
		//查看 档案
		$(".user-archivesList").on("click", ".keepArchives", function(event) {
			event.stopPropagation();
			toCheck($(this).find("span").attr("v"));
		});
		//删除档案
		$(".user-archivesList").on("touchstart", ".animat", function(event) {
			event.stopPropagation();
			deleteArchives($(this).children().attr("v"));
		});

	});
	//查看档案列表
	function toCheck($id) {
		var archivesId = $id;
		sessionStorage.setItem("index_archivesid",archivesId);
		location.href = "user-archives-check.html?index_archivesid="+archivesId;
	}
	//加载档案列表
	function initData() {
		var param = {
			"patientid": USERID
		};
		archivesModule.loadMyArchives(param, function(data) {
			console.log(data);
			var result = {};
			if(data != null) {
				result.list = data;	
				
			}
		utilModule.renderHtml("#dataBody", "dataDiv", result);
		});
	}
	//删除完成刷新列表
	function deleteArchives($id) {
		var para = {
			id: $id
		};
		var btnArray = ['否', '是'];
		mui.confirm('您确定删除该档案吗？', '提示', btnArray, function(e) {
			if(e.index == 1) {
				archivesModule.deleteMyArchives(para, function(result) {
					if(result.msg=="该档案下存在精防记录"){
						mui.alert("该档案下存在精防记录","提示");
					}else{
						initData();
					}
				})
			}
		})
	}
	//点击完成，跳转档案列表
	function toList() {
		var url = "user-archives-list.html";
		var skipType = sessionStorage.getItem("skipType");
		if(utilModule.checkUndefined(skipType) != "") {
			url += "?skipType="+skipType;
		}
		location.href = url;
	} 
	
   